package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.OrganizationService;
import com.yixun.qfbao.apidto.ImportCooOrgReqDto;
import com.yixun.qfbao.apidto.ImportCooOrgResDto;
import com.yixun.qfbao.apidto.ImportOrgResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.util.exception.TServerException;
import com.yixun.qfbao.utils.LoginUtils;
import com.yixun.qfbao.vo.ImportCooOrgReqVo;
import com.yixun.qfbao.vo.ImportOrgReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 合作机构批量导入
 * @author guifang.weng
 *
 */
@Service("importCooOrgHander")
public class ImportCooOrgHander {
	private static Logger logger= LoggerFactory.getLogger(ImportCooOrgHander.class);
	
	@Autowired
	private OrganizationService organizationService;

	public BaseResponseDTO doBusiness(ImportCooOrgReqVo reqDto1) {
		BaseResponseDTO<ImportCooOrgResDto> res = new BaseResponseDTO<>();
		ImportCooOrgResDto resDto = new ImportCooOrgResDto();
		try {
			resDto = organizationService.importCooOrg(reqDto1);
		}catch(TServerException e){
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg(e.getErrorMsg());
		} catch (Exception e) {
			logger.error("ImportCooOrgHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("系统异常");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}

}
